#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 2) {
        cout << "Usage: " << argv[0] << " infile" << endl;
        return 0;
    
    }
    
    string file_name(argv[1]);
    fstream fs;
    fs.open(file_name.c_str(), fstream::in);
    if (!fs.is_open()) {
        return 1;
    }

    string str_x, str_y;
    int x[4], y[4];
    int i;
    // 4 points in total
    for (i = 0; i < 4; i++) {
        fs >> str_x >> str_y;
        if (str_x.empty() || str_y.empty()) {
            break;
        }

        x[i] = atoi(str_x.c_str());
        y[i] = atoi(str_y.c_str());
    }

    bool ret_code;
    ret_code = lineIntersect(x[0], y[0], x[1], y[1], x[2], y[2], x[3], y[3]);
    if (ret_code) {
        cout << "Two lines intersect or overlap." << endl;
    }
    else {
        cout << "Tow lines are parallel." << endl;
    }
}

